name: Publish Snapshots

on:
  push:
    branches: [ master ]

jobs:
  publish-core-snapshot:
    runs-on: ubuntu-latest

    permissions:
      contents: read
      packages: write

    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-java@v3
        with:
          java-version: '11'
          distribution: 'temurin'

      - uses: gradle/actions/setup-gradle@v3
        with:
          validate-wrappers: true

      - name: Set snapshot version
        run: ./gradlew set-snapshot-version --stacktrace

      - name: Publish core package
        id: publish_package
        run: ./gradlew :publishMavenJavaPublicationToGitHubPackagesRepository --stacktrace

        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  publish-jetty12-snapshot:
    runs-on: ubuntu-latest

    permissions:
      contents: read
      packages: write

    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-java@v3
        with:
          java-version: '17'
          distribution: 'temurin'

      - uses: gradle/actions/setup-gradle@v3
        with:
          validate-wrappers: true

      - name: Set snapshot version
        run: ./gradlew set-snapshot-version --stacktrace

      - name: Publish Jetty 12 package
        id: publish_package
        run: ./gradlew :wiremock-jetty12:publishMavenJavaPublicationToGitHubPackagesRepository --stacktrace

        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
